<?php
	$curl = ($this->lang->lang() == 'vi' )? 1:$this->utility->currency('USD','VND','1');
?>

<!-- 'status' div is used as a container for interactive message blocks(success, warning, error, etc..) --> 
        	<div id="status"></div>
         	<!-- Information Block -->
            <div class="status info">
            	Features to explore: Click on the following buttons - Insert New Page, Delete (inside table). 
                Try to sort the table rows with drag&amp;drop.
            </div>
            <!-- END Information Block -->
           	<h2 class="top-title"><?php echo lang('product.header')?></h2>
            <form method="post" action="#" name="form">
                
                
                <!-- Filter Panel -->
                <div id="sort-panel">
                    <span class="bold"><?php echo lang('product.sort')?>:</span>
                    <select name="sorting" onchange="sortByStatus('<?php echo base_url($this->lang->lang() . '/product')?>',this.value);">
                    	<option value="-1" <?php if($publish == -1) echo "selected='selected'"?> ><?php echo lang('product.choose')?></option>
                    	<option value="1" <?php if($publish == 1) echo "selected='selected'"?> ><?php echo lang('product.published')?></option>
                        <option value="0" <?php if($publish == 0) echo "selected='selected'"?>><?php echo lang('product.unpublished')?></option>
                    </select>
                </div>
                 <!-- End Filter Panel -->
                
                <div class="clear"></div><!-- Clear floatting -->
                
                <?php if($permissions['insert']):?>
                <!-- New Page Button -->
                <div style="margin:10px 0px 20px 10px">
                	<a href="product-add.html" class="submit button large ui-corner-all"><?php echo lang('product.insert')?></a>
                </div>
               	<!-- END New Page Button -->
                <?php endif;?>
                 
                 
                 
                 
           		<table id="product-table" class="tablesorter list-table ">
            	<thead class="ui-widget-header ui-corner-all">
                	<tr>
                    	<th><?php echo lang('product.#')?></th>
                    	<th><input type="checkbox"" /></th>
                        <th>Sku</th>
                        <th><?php echo lang('product.name')?></th>
                        <th><?php echo lang('product.price')?></th>
                        <th><?php echo lang('product.discount')?></th>
                        <th><?php echo lang('product.quantity')?></th>
                        <th><?php echo lang('product.category')?></th>
                        <th><?php echo lang('product.manufacturer')?></th>
                        <th><?php echo lang('product.order')?></th>
                        <th><?php echo lang('product.publish')?></th>
                        <th colspan="4"><?php echo lang('product.action')?></th>
                    </tr>
                </thead>
                <tbody>
                	<?php $i = 1; ?>
                	<?php foreach ($products as $p){?>
                	<tr>
                     	<td><?php echo $i; ?></td>
                     	<td><input type="checkbox"" /></td>
                        <td><?php echo $p['sku']?></td>
                        <td><?php echo $p['name']?></td>
                        <td><?php echo $this->cart->format_number( round( $p['price'] / $curl , 4) )?> <?php echo lang('product.currency')?></td>
                        <td><?php echo $p['discount']?>%</td>
                        <td><?php echo $p['quantity']?></td>
                        <td><?php echo $p['category_name']?></td>
                        <td><?php echo $p['manufacturer_name']?></td>
                        <td><?php echo $p['order']?></td>
                        <td>
                        	<?php if($p['public'] == 1):?>
                        	<span class="button submit medium green-back fixed-width-100 ui-corner-all"><?php echo lang('product.published')?></span>
                        	<?php endif;?>
                        	
                        	<?php if($p['public'] == 0):?>
                        	<span class="button submit medium red-back fixed-width-100 ui-corner-all"><?php echo lang('product.unpublished')?></span>
                        	<?php endif;?>
						</td>
                        
                        <?php if($permissions['update'] == 1):?>
                        <td><a href="#" class="view-record"><?php echo lang('product.view')?></a></td>
                        <td><a href="#" class="edit-record"><?php echo lang('product.update')?></a></td>
                        <?php endif;?>
                        <?php if($permissions['delete']):?>
                        <td><a href="#" class="delete-record"><?php echo lang('product.delete')?></a></td>
                        <?php endif;?>
                        
                    </tr>
                	<?php $i++;?>
                	<?php };?>
                	
                    
                	
                    
                </tbody>
                </table>
           	</form>
           	<hr /> <!-- Divider -->
            
            <!-- Pagination -->
           	<div id="pagination">
           		<?php if($pg['total'] > 2):?>
           		
           		<a href="#" onclick="getObjectByPage('<?php echo base_url($this->lang->lang()) . '/product/index/'.$pg['first']?>')"><img src="<?php echo base_url() ?>resources/images/arrows/arrow_first.png" width="16" height="16" alt="Go to First Page" title="Go to first page" /></a>
				<a href="#" onclick="getObjectByPage('<?php echo base_url($this->lang->lang()) . '/product/index/'.$pg['prev']?>')"><img src="<?php echo base_url() ?>resources/images/arrows/arrow_previous.png" width="16" height="16" alt="Previous" title="Previous" /></a>
				
				<?php for ($i = $pg['first']; $i <= $pg['last']; $i++): ?>
					<?php if($i == $pg['page']){?>
					<span><?php echo $i?></span>
					<?php }else {?>
					<a href="#" onclick="getObjectByPage('<?php echo base_url($this->lang->lang()) . '/product/index/'.$i?>')"><?php echo $i?></a>
					<?php }?>
				<?php endfor;?> 
				
				<a href="#" onclick="getObjectByPage('<?php echo base_url($this->lang->lang()) . '/product/index/'.$pg['next']?>')"><img src="<?php echo base_url() ?>resources/images/arrows/arrow_next.png" width="16" height="16" alt="Next" title="Next" /></a>
                <a href="#" onclick="getObjectByPage('<?php echo base_url($this->lang->lang()) . '/product/index/'.$pg['last']?>')"><img src="<?php echo base_url() ?>resources/images/arrows/arrow_last.png" width="16" height="16" alt="Go to First Page" title="Go to last page" /></a>
                
           		<?php endif;?>
           		
           </div>
           <!-- End Pagination -->
           <script type="text/javascript">

           $(document).ready(function() 
          			{ 
          				$("#product-table").tablesorter();

          				/* Make Tables match JQuery UI's theme's style */
          				$(".list-table thead").addClass("ui-widget-header ui-corner-all");
          				$(".list-table tbody td").each(function(){
          					$(this).addClass("ui-widget-content");
          				});
          				$(".list-table tr").hover(
          					function()
          					{
          						$(this).children("td").addClass("ui-state-hover");
          					},
          					function()
          					{
          						$(this).children("td").removeClass("ui-state-hover");
          					}
          				);
          				$(".list-table tbody tr:odd").addClass("odd");
          				
          			}	 
          	);

</script>    